<%@page import="RssEasy.Core.CookieHelper"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="Model.Purchase.PurchaseMaterielList"%>
<%@page import="Model.Purchase.PurchaseList"%>
<%@page import="RssEasy.Core.DateTimeExtend"%>
<%@page import="RssEasy.Core.HttpRequestHelper"%>
<%
    HttpRequestHelper hrh = new HttpRequestHelper(pageContext).request();
    PurchaseList pl = new PurchaseList(pageContext);
    CookieHelper cookie=new CookieHelper(request, response);
    String level = cookie.Get("level");
    String myid;
    if (level.equals("0")) {
        myid = cookie.Get("myid");
    } else {
        myid = cookie.Get("level");
    }
   if(pl.select("name").where("myid=? and name=? and summary=? and conditions=?",myid,hrh.get("name"),hrh.get("summary"),hrh.get("conditions")).get_first_rows()){
        out.print("2");
    }else{
    pl.keyvalue("myid",myid).keyvalue("name", hrh.get("name")).keyvalue("summary", hrh.get("summary")).keyvalue("conditions", hrh.get("conditions")).keyvalue("purchase_class",hrh.get("purchase_class"))
            .keyvalue("enddt", DateTimeExtend.timestamp(hrh.get("enddt"), "yyyy-MM-dd")).keyvalue("typid",2).keyvalue("sourcefile", hrh.get("attachurl")).keyvalue("business_class", hrh.get("product2"));
    pl.timestamp();
    pl.append().submit();
    out.print("1");
    }
%>